﻿using CustomBA.Models;
using CustomBA.ViewModels;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace CustomBA.Views
{
	/// <summary>
	/// Interaction logic for SetUpPage.xaml
	/// </summary>
	public partial class InstallPage : System.Windows.Controls.UserControl
	{
		public InstallPage()
		{
			InitializeComponent();
			this.DataContext = new InstallPageViewModel();
		}

		private void CheckBox_Checked(object sender, RoutedEventArgs e)
		{
			MainInstall.Visibility = Visibility.Visible;
			//创建动画使用 故事板（Storyboard）
			Storyboard storyboard = new Storyboard();

			//定义变更大小的动画 
			//根据属性的类型设置动画的类型。 因为下面设置的属性 Width 是 double 类型的属性，故使用DoubleAnimation
			DoubleAnimation doubleAnimation = new DoubleAnimation();

			//设置动画起始值
			doubleAnimation.From = -150;
			//设置动画结束值
			doubleAnimation.To = 0;

			//设置动画在原有的基础上增加一个范围
			//doubleAnimation.By = 30;

			doubleAnimation.Duration = TimeSpan.FromSeconds(0.4);
			//设置动画无限次播放(不设置的话默认是无限次)
			//doubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
			//设置动画在指示时间线在完成向前迭代后是否按相反的顺序播放，从而实现反复的效果
			doubleAnimation.AutoReverse = false;
			//绑定到控件
			Storyboard.SetTarget(doubleAnimation, anima);
			anima.RenderTransform = new TranslateTransform(0, 0);
			//绑定到控件的依赖属性
			Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.Y)"));

			//将动画添加到故事板
			storyboard.Children.Add(doubleAnimation);

			//启动故事板包含的所有动画
			storyboard.Begin(this);

		}
		private void CheckBox_UnChecked(object sender, RoutedEventArgs e)
		{
			MainInstall.Visibility = Visibility.Visible;
			//创建动画使用 故事板（Storyboard）
			Storyboard storyboard = new Storyboard();

			//定义变更大小的动画 
			//根据属性的类型设置动画的类型。 因为下面设置的属性 Width 是 double 类型的属性，故使用DoubleAnimation
			DoubleAnimation doubleAnimation = new DoubleAnimation();

			//设置动画起始值
			doubleAnimation.From = 0;
			//设置动画结束值
			doubleAnimation.To = -150;

			//设置动画在原有的基础上增加一个范围
			//doubleAnimation.By = 30;

			doubleAnimation.Duration = TimeSpan.FromSeconds(0.4);
			//设置动画无限次播放(不设置的话默认是无限次)
			//doubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
			//设置动画在指示时间线在完成向前迭代后是否按相反的顺序播放，从而实现反复的效果
			doubleAnimation.AutoReverse = false;
			//绑定到控件
			Storyboard.SetTarget(doubleAnimation, anima);
			anima.RenderTransform = new TranslateTransform(0, 0);
			//绑定到控件的依赖属性
			Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("(UIElement.RenderTransform).(TranslateTransform.Y)"));

			//将动画添加到故事板
			storyboard.Children.Add(doubleAnimation);

			//启动故事板包含的所有动画
			storyboard.Begin(this);

		}

	}


}
